<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head th:include="_meta :: header">
    <title>稿件校对组长</title>
</head>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">稿件校对组长</a>
            <a>
              <cite>稿件校对组长抽查</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="float: right;height: 30px;line-height: 30px;margin-top: 5px;" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form action="#" class="layui-form layui-col-space5" th:action="@{/distribute/draftCheckLeader/checkerIndex}" method="post">
<!--                        <div class="layui-inline ">-->
<!--                            <input type="text"  step="0.001" class="layui-input"  th:value="${searchInfo.draftTitle}" name="draftTitle" placeholder="搜索稿件标题" id="draftTitle" />-->
<!--                        </div>-->
<!--                        <div class="layui-inline ">-->
<!--                            <select id="groupId" name="groupId" >-->
<!--                                <option value=0 text="请选择">请选择</option>-->
<!--                                <option  th:selected="${searchInfoId eq g.key}"-->
<!--                                         th:each="g:${draftGroup}"  th:value="${g.key}" th:text="${g.value}">-->
<!--                                    ${g.value}-->
<!--                                </option>-->
<!--                            </select>-->
<!--                        </div>-->
                            <div class="layui-inline ">
                                <input type="hidden"  id="dsadas"name="sdas"  th:value="${needCheckSize}">
                                <select id="groupId" name="groupId"  lay-filter="category" th:field="${searchInfo.groupId}" >
                                    <option value="" text="请选择">请选择组名</option>
                                    <option th:each="g:${groups}"  th:value="${g.key}" th:text="${g.value}">
                                    </option>
                                </select>
                            </div>
<!--                                <option  th:selected="${searchInfo.draftType eq c.key}"-->
<!--                                         th:each="c:${draftTypes}"  th:value="${c.key}" th:text="${c.value}"-->
<!--                                         value="1">${c.value}-->
<!--                                </option>-->
<!--                            </select>-->
<!--                        </div>-->
<!--                        <div class="layui-inline ">-->
<!--                            <input type="text"  step="0.001" class="layui-input"  th:value="${searchInfo.statusCode}" name="statusCode" placeholder="搜索稿件流程" id="statusCode" />-->
<!--                        </div>-->
<!--                        <div class="layui-inline ">-->
<!--                            <select id="isPass" name="isPass">-->
<!--                                <option value=0 text="请选择">请选择</option>-->
<!--                                <option  th:selected="${searchInfo.isPass eq c.key}"-->
<!--                                         th:each="c:${draftCheckStatus}"  th:value="${c.key}" th:text="${c.value}"-->
<!--                                         value="1">${c.value}-->
<!--                                </option>-->
<!--                            </select>-->
<!--                        </div>-->
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn  layui-btn-success radius"><i class="layui-icon">&#xe615;</i>
                            </button>
                        </div>
                        <div class="cl pd-5 bg-1 bk-gray " >
							<span class="l">
                                <a href="javascript:;"
                                   onclick="Vsuccess('/distribute/draftCheckLeader/check')"
                                   class="layui-btn  layui-btn-normal radius"><i class="layui-icon">&#xe605;</i> 批量通过</a>
</span>
<!--						<a href="javascript:;"-->
<!--                           onclick="layer_show('添加','/draft/draft/addBefore',900,500)"-->
<!--                           class="layui-btn  layui-btn-normal radius"><i class="layui-icon">&#xe600;</i> 添加</a>-->
							</span>
                            <span class="r wei-height" style="float: right;margin-right: 20px">共有数据：<strong
                                    th:text="${pageInfo.total}"></strong> 条</span>
                        </div>
                        <div class="layui-card-body" style="text-align: center">
                            <table class="layui-table layui-form">
                                <thead>
                                <tr class="text-c">
                                    <th width="25"><input type="checkbox" name="" value="" lay-filter="checkall" lay-skin="primary"/></th>
                                    <th width="25">序号</th>
                                    <th width="40">稿件标题</th>
                                    <th width="40">稿件字数</th>
                                    <th width="40">稿件类型 </th>
                                    <th width="40">提交时间</th>
                                    <th width="40">流程状态</th>
                                    <th width="40">是否通过</th>
                                    <th width="40">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr class="text-c" th:if="${pageInfo.list.size() == 0}">
                                    <td colspan="15"><strong>暂无数据</strong></td>
                                </tr>
                                <tr class="text-c" th:each="draft,count:${pageInfo.list}">
                                    <td><input type="checkbox" value="" th:value="${draft.id}"
                                               name="id" lay-skin="primary"/></td>
                                    <td th:text="${count.count}"></td>
                                    <td th:text="${draft.draftTitle}"></td>
                                    <td th:text="${draft.draftNum}"></td>
                                    <td th:text="${draftTypes[draft.draftType]}"></td>
                                    <td th:text="${#temporals.format(draft.submitTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
                                    <td th:text="${stateDic[draft.statusCode]}"></td>
                                    <td th:text="${draftCheckStatus[draft.isPass]}"></td>
                                    <td class="td-manage">
                                        <a title="预览"
                                           th:onclick="'javascript:layer_show(\'预览\',\'/draft/'+'writer'+'/previewlist/'+${draft.id}+'?checkFlag=1001&buttonFlag=1001&agreeFlag=1001&updateFlag=1001\',900,500)'"
                                           class="ml-5" style="text-decoration:none"><i class="layui-icon">&#xe615;</i></a>
<!--                                        <a title="驳回" href="javascript:;"-->
<!--                                           th:onclick="'javascript:disallowUtil(\'/draft/draftFinal/disallowUtil\',' + '\'' + ${draft.id} + '\')'"-->
<!--                                           class="ml-5" style="text-decoration:none"><i class="layui-icon">&#x1006;</i></a>-->
<!--                                        <a title="通过" href="javascript:;" th:onclick="'pass(' + ${draft.id} + ')'"-->
<!--                                           class="ml-5" style="text-decoration:none"><i class="layui-icon">&#xe605;</i></a>-->
<!--                                        <a title="驳回" href="javascript:;"-->
<!--                                           th:onclick="'javascript:layer_show(\'驳回\',\'/distribute/'+'draftCheckLeader'+'/LeaderfailedBefore/'+${draft.id}+'\',900,500)'"-->
<!--                                           class="layui-btn  layui-btn-normal radius" style="text-decoration:none"><i class="layui-icon">&#xe640;</i>驳回</a>-->
                                        <a title="操作记录" href="javascript:;"
                                           th:onclick="'javascript:layer_show(\'操作记录\',\'/admin/'+'draftLog'+'/operation/'+${draft.id}+'\',1000,500)'"
                                           class="ml-5" style="text-decoration:none"><i class="layui-icon">&#xe60e;</i></a>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div th:include="_pagination :: page"></div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
<div th:replace="_footer :: footerjs">
</div>
<!--/_footer 作为公共模版分离出去-->
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;
        console.log("dsfdsfdsfds==================="+$("#groupId").val());
        // 监听全选
        form.on('checkbox(checkall)', function(data){

            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });
        form.on('select(selectchange)', function(data){
            console.log(data.value); //得到被选中的值
            var pageNo = $('#pageNo');
            var Form = $('form')
            pageNo.val(1);
            Form.submit();
            form.render('select');
        });
        //日期时间范围选择
        laydate.render({

        });
        lay('.timeSpace').each(function(){
            laydate.render({
                elem: this
                ,type: 'datetime'
                ,range: true //或 range: '~' 来自定义分割字符
            });
        });
    });
    function pass() {
        layer.open({
            title: '审核提示',
            content: '确认审核通过吗?',
            btn: ['确认', '取消'],
            yes: function(index, layero){//两个参数:当前层索引,当前层DOM对象
                //按钮【确认】的回调
                var draftGroup=$("#groupId").val();
                $.lock()
                $.ajax({
                    type:'post',
                    url:"/distribute/draftCheckLeader/check",
                    cache: false,
                    data:{"draftGroup":draftGroup},  //重点必须为一个变量如：data
                    dataType:'json',
                    success:function(data){
                        if (data.code == "1") {
                            selfmsg('提交成功!', 1, function () {
                                window.location.reload();
                            });
                        }else {
                            selfmsg('提交失败!');
                            $.unlock();
                        }
                    },
                    error:function(){
                        selfmsg('提交异常!',5);
                        $.unlock();
                    }
                });
            },
        });
    };

    function checkAll(url){
        var ids = "";
        $('input[name="id"]:checked').each(
                function (i){
                    ids += $(this).val()+",";
                });
        if(ids.trim().length == 0){
            layer.msg("您还未选择要分配的数据");
            return false;
        }
        layer_show("分配",url+"?ids="+ids);
    };

    var Vsuccess = function (url) {
        var sum=$('#dsadas').val();
        console.log(sum);
        var _list = new Array();
        $('input[name="id"]:checked').each(
            function (i) {
                _list[i] = $(this).val();
            });
        if(_list.length == 0){
            layer.msg("请选择审核的数据");
            return false;
        }
        if(_list.length != sum){
            layer.msg("还有"+(sum-_list.length)+"个稿件未校对！");
            return false;
        }
        $.lock()
        $.ajax({
            url: url,// 跳转到 action
            data: JSON.stringify(_list),
            type: 'post',
            cache: false,
            dataType: 'json',
            contentType: "application/json",  //发送信息至服务器时内容编码类型。
            success: function (data) {
                if (data.code == "1") {
                    layer.msg('审核成功!', {
                        icon: 1, time: 1000, end: function () {
                            location.reload();
                        }
                    });
                } else {
                    selfmsg('审核失败!');
                    $.unlock();
                }
            },
            error: function () {
                selfmsg('审核异常!', 5);
                $.unlock();
            },
        });
    }
</script>
</body>
</html>